home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / python-support / python2.6 / gdata / tlslite / constants.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  7.4 KB  |  234 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''Constants used in various places.'''
  5.  
  6. class CertificateType:
  7.     x509 = 0
  8.     openpgp = 1
  9.     cryptoID = 2
  10.  
  11.  
  12. class HandshakeType:
  13.     hello_request = 0
  14.     client_hello = 1
  15.     server_hello = 2
  16.     certificate = 11
  17.     server_key_exchange = 12
  18.     certificate_request = 13
  19.     server_hello_done = 14
  20.     certificate_verify = 15
  21.     client_key_exchange = 16
  22.     finished = 20
  23.  
  24.  
  25. class ContentType:
  26.     change_cipher_spec = 20
  27.     alert = 21
  28.     handshake = 22
  29.     application_data = 23
  30.     all = (20, 21, 22, 23)
  31.  
  32.  
  33. class AlertLevel:
  34.     warning = 1
  35.     fatal = 2
  36.  
  37.  
  38. class AlertDescription:
  39.     """
  40.     @cvar bad_record_mac: A TLS record failed to decrypt properly.
  41.  
  42.     If this occurs during a shared-key or SRP handshake it most likely
  43.     indicates a bad password.  It may also indicate an implementation
  44.     error, or some tampering with the data in transit.
  45.  
  46.     This alert will be signalled by the server if the SRP password is bad.  It
  47.     may also be signalled by the server if the SRP username is unknown to the
  48.     server, but it doesn't wish to reveal that fact.
  49.  
  50.     This alert will be signalled by the client if the shared-key username is
  51.     bad.
  52.  
  53.     @cvar handshake_failure: A problem occurred while handshaking.
  54.  
  55.     This typically indicates a lack of common ciphersuites between client and
  56.     server, or some other disagreement (about SRP parameters or key sizes,
  57.     for example).
  58.  
  59.     @cvar protocol_version: The other party's SSL/TLS version was unacceptable.
  60.  
  61.     This indicates that the client and server couldn't agree on which version
  62.     of SSL or TLS to use.
  63.  
  64.     @cvar user_canceled: The handshake is being cancelled for some reason.
  65.  
  66.     """
  67.     close_notify = 0
  68.     unexpected_message = 10
  69.     bad_record_mac = 20
  70.     decryption_failed = 21
  71.     record_overflow = 22
  72.     decompression_failure = 30
  73.     handshake_failure = 40
  74.     no_certificate = 41
  75.     bad_certificate = 42
  76.     unsupported_certificate = 43
  77.     certificate_revoked = 44
  78.     certificate_expired = 45
  79.     certificate_unknown = 46
  80.     illegal_parameter = 47
  81.     unknown_ca = 48
  82.     access_denied = 49
  83.     decode_error = 50
  84.     decrypt_error = 51
  85.     export_restriction = 60
  86.     protocol_version = 70
  87.     insufficient_security = 71
  88.     internal_error = 80
  89.     user_canceled = 90
  90.     no_renegotiation = 100
  91.     unknown_srp_username = 120
  92.     missing_srp_username = 121
  93.     untrusted_srp_parameters = 122
  94.  
  95.  
  96. class CipherSuite:
  97.     TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA = 80
  98.     TLS_SRP_SHA_WITH_AES_128_CBC_SHA = 83
  99.     TLS_SRP_SHA_WITH_AES_256_CBC_SHA = 86
  100.     TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA = 81
  101.     TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA = 84
  102.     TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA = 87
  103.     TLS_RSA_WITH_3DES_EDE_CBC_SHA = 10
  104.     TLS_RSA_WITH_AES_128_CBC_SHA = 47
  105.     TLS_RSA_WITH_AES_256_CBC_SHA = 53
  106.     TLS_RSA_WITH_RC4_128_SHA = 5
  107.     srpSuites = []
  108.     srpSuites.append(TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA)
  109.     srpSuites.append(TLS_SRP_SHA_WITH_AES_128_CBC_SHA)
  110.     srpSuites.append(TLS_SRP_SHA_WITH_AES_256_CBC_SHA)
  111.     
  112.     def getSrpSuites(ciphers):
  113.         suites = []
  114.         for cipher in ciphers:
  115.             if cipher == 'aes128':
  116.                 suites.append(CipherSuite.TLS_SRP_SHA_WITH_AES_128_CBC_SHA)
  117.                 continue
  118.             if cipher == 'aes256':
  119.                 suites.append(CipherSuite.TLS_SRP_SHA_WITH_AES_256_CBC_SHA)
  120.                 continue
  121.             if cipher == '3des':
  122.                 suites.append(CipherSuite.TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA)
  123.                 continue
  124.         
  125.         return suites
  126.  
  127.     getSrpSuites = staticmethod(getSrpSuites)
  128.     srpRsaSuites = []
  129.     srpRsaSuites.append(TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA)
  130.     srpRsaSuites.append(TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA)
  131.     srpRsaSuites.append(TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA)
  132.     
  133.     def getSrpRsaSuites(ciphers):
  134.         suites = []
  135.         for cipher in ciphers:
  136.             if cipher == 'aes128':
  137.                 suites.append(CipherSuite.TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA)
  138.                 continue
  139.             if cipher == 'aes256':
  140.                 suites.append(CipherSuite.TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA)
  141.                 continue
  142.             if cipher == '3des':
  143.                 suites.append(CipherSuite.TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA)
  144.                 continue
  145.         
  146.         return suites
  147.  
  148.     getSrpRsaSuites = staticmethod(getSrpRsaSuites)
  149.     rsaSuites = []
  150.     rsaSuites.append(TLS_RSA_WITH_3DES_EDE_CBC_SHA)
  151.     rsaSuites.append(TLS_RSA_WITH_AES_128_CBC_SHA)
  152.     rsaSuites.append(TLS_RSA_WITH_AES_256_CBC_SHA)
  153.     rsaSuites.append(TLS_RSA_WITH_RC4_128_SHA)
  154.     
  155.     def getRsaSuites(ciphers):
  156.         suites = []
  157.         for cipher in ciphers:
  158.             if cipher == 'aes128':
  159.                 suites.append(CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA)
  160.                 continue
  161.             if cipher == 'aes256':
  162.                 suites.append(CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA)
  163.                 continue
  164.             if cipher == 'rc4':
  165.                 suites.append(CipherSuite.TLS_RSA_WITH_RC4_128_SHA)
  166.                 continue
  167.             if cipher == '3des':
  168.                 suites.append(CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA)
  169.                 continue
  170.         
  171.         return suites
  172.  
  173.     getRsaSuites = staticmethod(getRsaSuites)
  174.     tripleDESSuites = []
  175.     tripleDESSuites.append(TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA)
  176.     tripleDESSuites.append(TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA)
  177.     tripleDESSuites.append(TLS_RSA_WITH_3DES_EDE_CBC_SHA)
  178.     aes128Suites = []
  179.     aes128Suites.append(TLS_SRP_SHA_WITH_AES_128_CBC_SHA)
  180.     aes128Suites.append(TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA)
  181.     aes128Suites.append(TLS_RSA_WITH_AES_128_CBC_SHA)
  182.     aes256Suites = []
  183.     aes256Suites.append(TLS_SRP_SHA_WITH_AES_256_CBC_SHA)
  184.     aes256Suites.append(TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA)
  185.     aes256Suites.append(TLS_RSA_WITH_AES_256_CBC_SHA)
  186.     rc4Suites = []
  187.     rc4Suites.append(TLS_RSA_WITH_RC4_128_SHA)
  188.  
  189.  
  190. class Fault:
  191.     badUsername = 101
  192.     badPassword = 102
  193.     badA = 103
  194.     clientSrpFaults = range(101, 104)
  195.     badVerifyMessage = 601
  196.     clientCertFaults = range(601, 602)
  197.     badPremasterPadding = 501
  198.     shortPremasterSecret = 502
  199.     clientNoAuthFaults = range(501, 503)
  200.     badIdentifier = 401
  201.     badSharedKey = 402
  202.     clientSharedKeyFaults = range(401, 403)
  203.     badB = 201
  204.     serverFaults = range(201, 202)
  205.     badFinished = 300
  206.     badMAC = 301
  207.     badPadding = 302
  208.     genericFaults = range(300, 303)
  209.     faultAlerts = {
  210.         badUsername: (AlertDescription.unknown_srp_username, AlertDescription.bad_record_mac),
  211.         badPassword: (AlertDescription.bad_record_mac,),
  212.         badA: (AlertDescription.illegal_parameter,),
  213.         badIdentifier: (AlertDescription.handshake_failure,),
  214.         badSharedKey: (AlertDescription.bad_record_mac,),
  215.         badPremasterPadding: (AlertDescription.bad_record_mac,),
  216.         shortPremasterSecret: (AlertDescription.bad_record_mac,),
  217.         badVerifyMessage: (AlertDescription.decrypt_error,),
  218.         badFinished: (AlertDescription.decrypt_error,),
  219.         badMAC: (AlertDescription.bad_record_mac,),
  220.         badPadding: (AlertDescription.bad_record_mac,) }
  221.     faultNames = {
  222.         badUsername: 'bad username',
  223.         badPassword: 'bad password',
  224.         badA: 'bad A',
  225.         badIdentifier: 'bad identifier',
  226.         badSharedKey: 'bad sharedkey',
  227.         badPremasterPadding: 'bad premaster padding',
  228.         shortPremasterSecret: 'short premaster secret',
  229.         badVerifyMessage: 'bad verify message',
  230.         badFinished: 'bad finished message',
  231.         badMAC: 'bad MAC',
  232.         badPadding: 'bad padding' }
  233.  
  234.